package com.lemner.www.hongyu.Fragement;


import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import com.lemner.www.hongyu.Activity.UndistributedOrderActivity;
import com.lemner.www.hongyu.Bean.Userbean;
import com.lemner.www.hongyu.R;



public class OrderFragment extends Fragment {
    private TextView tv_lookorder;
    private Button btn_address;
    private  View view;
    private  Userbean.DataBean date;
    public int id,id2;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        view=inflater.inflate(R.layout.fragment_order,container,false);
        InitView();
        Bundle bundle=getArguments();
        date=(Userbean.DataBean)bundle.getSerializable("date");
        return view;
    }

    public void InitView(){
        tv_lookorder=(TextView)view.findViewById(R.id.tv_lookorder);
        btn_address=(Button)view.findViewById(R.id.btn_address);
        tv_lookorder.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(getActivity(), UndistributedOrderActivity.class);
                intent.putExtra("date",date);
                startActivity(intent);
            }
        });
    }

    @Override
    public void onResume() {
        super.onResume();
        if(date!=null){
            btn_address.setText(date.getUser().getCommunity_data().get(0).getCommunity_name());
        }
        else{
            Toast.makeText(getActivity(),"没能获取到数据",Toast.LENGTH_SHORT).show();
        }
    }


}
